package com.guessgame;

import java.util.Scanner;
import com.guessgame.pojo.Machine;
import com.guessgame.pojo.User;
import com.guessgame.referee.Judge;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class GuessGame {
    public static void main(String[] args) {
        int win = 0, fail = 0;//计数胜场
        log.info("-----程序已启动-----");
        log.info("石头剪刀布人机对决");
        log.info("请选择对局次数：");
        Scanner n = new Scanner(System.in);
        int no = n.nextInt();//对局次数
        for ( int i = 1; i <= no; i++) {
            log.info("第" + i + "局");
            System.out.print("请出拳：");
            Machine machine = new Machine();
            int computer = machine.num;
            User user = new User();
            int player = user.num;
            Judge judge = new Judge();
            judge.end(computer, player);
            while (true) {
                switch (computer){
                    case 1:
                        log.info("电脑本局出的是石头");
                        break;
                    case 2:
                        log.info("电脑本局出的是剪刀");
                        break;
                    case 3:
                        log.info("电脑本局出的是布");
                        break;
                    default:
                        break;
                }
                if (((computer - player) + 3) % 3 == 1) {
                    log.info("你赢了\n");
                    win++;
                    break;
                }
                else if (((computer - player) + 3) % 3 == 2) {
                    log.info("你输了\n");
                    fail++;
                    break;
                }
                else if (computer == player) {
                    log.info("打平了\n");
                    break;
                }
                else {
                    System.out.print("请重新选择：");
                }
                player = n.nextInt();
            }
        }
        //判别最终结果
        if (win > fail) {
            log.info("最终结果：胜利");
        }
        else if (win < fail) {
            log.info("最终结果：失败");
        }
        else {
            log.info("最终结果：和局");
        }
    }
}
/*
int win = 0, fail = 0;//计数胜场
        log.info("-----程序已启动-----");
        log.info("石头剪刀布人机对决");
        log.info("请选择对局次数：");
        Scanner n = new Scanner(System.in);
        int no = n.nextInt();//对局次数
        for ( int i = 1; i <= no; i++) {
            log.info("第" + i + "局");
            System.out.print("请出拳：");
            Machine machine = new Machine();
            int computer = machine.num;
            User user = new User();
            int player = user.num;
            Judge judge = new Judge();
            judge.end(computer, player);
            while (true) {
                switch (computer){
                    case 1:
                        log.info("电脑本局出的是石头");
                        break;
                    case 2:
                        log.info("电脑本局出的是剪刀");
                        break;
                    case 3:
                        log.info("电脑本局出的是布");
                        break;
                    default:
                        break;
                }
                if (((computer - player) + 3) % 3 == 1) {
                    log.info("你赢了\n");
                    win++;
                    break;
                }
                else if (((computer - player) + 3) % 3 == 2) {
                    log.info("你输了\n");
                    fail++;
                    break;
                }
                else if (computer == player) {
                    log.info("打平了\n");
                    break;
                }
                else {
                    System.out.print("请重新选择：");
                }
                player = n.nextInt();
            }
        }
        //判别最终结果
        if (win > fail) {
            log.info("最终结果：胜利");
        }
        else if (win < fail) {
            log.info("最终结果：失败");
        }
        else {
            log.info("最终结果：和局");
        }
 */